package com.wanyang.core.log.pattern;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.helpers.PatternParser;
import org.apache.log4j.spi.LoggingEvent;

/**
 * Created by zhai on 15/12/24.
 */
public class HxzPatternLayout extends PatternLayout {
    private String showStackTrace;

    public String getShowStackTrace() {
        return showStackTrace;
    }

    public void setShowStackTrace(String showStackTrace) {
        this.showStackTrace = showStackTrace;
    }

    @Override
    protected PatternParser createPatternParser(String pattern) {
        return new HxzPatternParser(pattern);
    }

    @Override
    public String format(LoggingEvent event) {
        return super.format(event);
    }

    @Override
    public boolean ignoresThrowable() {
        if (StringUtils.isBlank(showStackTrace))
            return true;
        return Boolean.valueOf(showStackTrace);
    }
}
